{% extends 'layout.html' %}

{#title#}
{% block title %}
    <title>用户主页</title>
{% endblock %}


{#content#}
{% block content %}
    <a href="{% url 'user_add' %}">
        <button class=" btn btn-primary btn-sm" style="margin-bottom: 10px">新增</button>
    </a>
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">用户列表</div>
        <!-- Table -->
        <table class="table table-hover table-bordered">
            <tr>
                <th>序号</th>
                <th>用户名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>部门</th>
                <th>操作</th>
            </tr>
            {% for user in users %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ user.username }}</td>
                    <td>{{ user.age }}</td>
                    {#    gender  1  get_属性名_display      #}
                    <td>{{ user.get_gender_display }}</td>
                    <td>{{ user.department.name }}</td>
                    <td>
                        <a href="{% url 'user_edit' %}?id={{ user.id }}">
                            <button class=" btn btn-primary btn-sm">编辑</button>
                        </a>
                        <a href="{% url 'user_delete' user.id %}">
                            <button class=" btn btn-danger btn-sm">删除</button>
                        </a>
                         <a href="{% url 'user_reset' user.id %}">
                            <button class=" btn btn-warning btn-sm">重置密码</button>
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </table>
    </div>
{% endblock %}